import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'
import config from '../config'

const cfg = new DocumentBuilder()
  .setTitle(config.swagger.title)
  .setDescription(config.swagger.description)
  .setVersion(config.swagger.version)
  .addBearerAuth({
    type: 'apiKey',
    in: 'header',
    name: 'token',
  })
  // .addTag('Nestjs')
  .build()

export function regSwagger(app): void {
  const document = SwaggerModule.createDocument(app, cfg)
  SwaggerModule.setup(config.swagger.path, app, document)
}
